package com.yuxi.controller;

import com.yuxi.entity.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yuxi on 2017/5/10.
 */
@RestController
@EnableConfigurationProperties({Account.class})
public class HelloController {
    //自定义属性
    @Value(value = "${boot.userName}")
    private String userName;
    @Autowired
    private Account account;


    /**
     * 重新定义配置文件 属性自定义
     *
     * @return
     */
    @RequestMapping("/file")
    public Object getFileProperties() {
        System.out.println(account);
        return account.toString();
    }

    /**
     * welcome spring boot
     *
     * @return
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {
        return "Greetings from Spring Boot! ";
    }

    /**
     * 简单 属性自定义
     *
     * @return
     */
    @RequestMapping("/user")
    public String getProperties() {
        System.out.println(userName);
        return userName;
    }

}
